package com.taglab.chic.atom;

import java.io.Serializable;

/**
 * @author Markus Kobler
 */
public class Category implements Serializable {

  private static final long serialVersionUID = -4440985073784217665L;
  
  // required
  private String term;

  // optional
  private String scheme;
  private String label;

  public Category(String term) {
    if( term == null ) throw new NullPointerException("term cannot be null");
    this.term = term;
  }   

  public String getTerm() {
    return term;
  }

  public String getScheme() {
    return scheme;
  }

  public void setScheme(String scheme) {
    this.scheme = scheme;
  }

  public String getLabel() {
    return label;
  }

  public void setLabel(String label) {
    this.label = label;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;

    Category category = (Category) o;

    if (label != null ? !label.equals(category.label) : category.label != null) return false;
    if (scheme != null ? !scheme.equals(category.scheme) : category.scheme != null) return false;
    if (!term.equals(category.term)) return false;

    return true;
  }

  @Override
  public int hashCode() {
    int result = term.hashCode();
    result = 31 * result + (scheme != null ? scheme.hashCode() : 0);
    result = 31 * result + (label != null ? label.hashCode() : 0);
    return result;
  }

  @Override
  public String toString() {
    final StringBuilder sb = new StringBuilder();
    sb.append("Category");
    sb.append("{term='").append(term).append('\'');
    sb.append(", scheme=").append(scheme);
    sb.append(", label='").append(label).append('\'');
    sb.append('}');
    return sb.toString();
  }
  
}
